package com.corpdata.mp.login.service;

import com.alibaba.fastjson.JSON;
import com.corpdata.common.utils.OkHttpUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 小程序登录服务
 * @auther: Zealon
 * @Date: 2018-08-06 15:50
 */
@Service
public class MpLoginService {

    /**
     * 登录
     * @param code
     * @return
     */
    public Map<String,Object> doLogin(String code){
        String appId = "wx6e09a41021d4457b";
        String secret = "50b0efdade277fdbafbce5126e1c872a";
        String uri = "https://api.weixin.qq.com/sns/jscode2session?appid="+appId+
                "&secret="+secret+"&js_code="+code+"&grant_type=authorization_code";
        String result = OkHttpUtil.get(uri,null);
        System.out.println(result);
        return JSON.parseObject(result);
    }
}
